package Offer.offer2019;

import domain.TreeNode;

/**
 * 二叉树的镜像
 * @author: leiwenkang02@meituan.com
 * @date: 2019/4/29
 * @time: 20:16
 */
public class Offer19 {

    public void mirrorTree(TreeNode root) {
        if (root == null) {
            return;
        }

        //交换根结点的左右节点
        TreeNode temp = root.left;
        root.left = root.right;
        root.right = temp;


        if (root.left != null) {
            mirrorTree(root.left);
        }

        if (root.right != null) {
            mirrorTree(root.right);
        }
    }
}
